package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author bss
 * @version V1.0
 * @Project maven
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/9/29 21:05
 */
@Controller
//@RequestMapping("/test")
public class ParamController {

    @RequestMapping("/echo")
    public String echo(){
        System.out.println("hello");
        return "index";
    }

    @RequestMapping("/param")
    public String param(HttpServletRequest request){
        String id = request.getParameter("id");
        System.out.println(id);
        return "index";
    }

    @RequestMapping("/param01")
    public String param01(Integer id,String name){
        System.out.println(id);
        System.out.println(name);
        return "index";
    }

    @RequestMapping("/param02")
    public String param02(User user){
        System.out.println(user);
        return "index";
    }

//       @RequestParam("list"): 绑定参数
//          value： 绑定参数名
//          required：默认为true  true表示必传，false可不传
//          defaultValue： 设置默认值
//

    @RequestMapping("/param03")
    public String param03(@RequestParam("list") List<String > list){
        System.out.println(list);
        return "index";
    }

    @RequestMapping("/param04")
    public String param04( String[] arr){
        System.out.println(arr);
        return "index";
    }

}
